package main.pl.pawellinkshell.liczbaa;

public class Liczbaa {

	public Liczbaa() {
		super();
		this.number = 0;
	}
	
	public Liczbaa(int number){
		super();
		this.number = number;
	}
	
	public String baseSystem (int base) throws Exception{
	      if(base > 16){
	    	  	throw new LiczbaaException("Podstawa wieksza niz 16");
	      }
	      if(base < 2){
	    	  throw new LiczbaaException("Podstawa mniejsza niz 2");
	      }
	      if(base == 10)
	          return  Integer.toString(number);
	      else
	      {
	          int pomoc, liczba = number;
	          String reverse = new String();
	          while(liczba != 0)
	          {
	              pomoc = liczba % base;
	              liczba /= base; 
	              if(pomoc == 0) reverse += "0";
	              if(pomoc == 1) reverse += "1";
	              if(pomoc == 2) reverse += "2";
	              if(pomoc == 3) reverse += "3";
	              if(pomoc == 4) reverse += "4";
	              if(pomoc == 5) reverse += "5";
	              if(pomoc == 6) reverse += "6";
	              if(pomoc == 7) reverse += "7";
	              if(pomoc == 8) reverse += "8";
	              if(pomoc == 9) reverse += "9";
	              if(pomoc == 10) reverse += "A";
	              if(pomoc == 11) reverse += "B";
	              if(pomoc == 12) reverse += "C";
	              if(pomoc == 13) reverse += "D";
	              if(pomoc == 14) reverse += "E";
	              if(pomoc == 15) reverse += "F";
	          }
				String wynik = new StringBuffer(reverse).reverse().toString();
				return wynik;
	      } 
	   }
	
	public boolean isNotZero(){
		return (this.number != 0) ? true : false;
	}
	
	public int getNumber() {
		return number;
	}

	public void setNumber(int number) {
		this.number = number;
	}
	
	
	public static void main(String[] args) throws Exception {
		Liczbaa num = new Liczbaa(10);
		
		for (int i = 2; i < 16; i++) {
			System.out.println(num.baseSystem(i));
		}
	
		
	}
	
	private int number;


}
